﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Agent_AskList : System.Web.UI.UserControl
{
    public int FetchNum = 5;
    protected bool hasAnswer;
    protected int categoryID;
    protected void Page_Load(object sender, EventArgs e)
    {
        MatchIns.BLL.PageInfo PI = new MatchIns.BLL.PageInfo(FetchNum, 1);
        pager.PageSize = PI.PageSize;
        PI.Where = "where 1=1";
        if (Request.QueryString["status"] == "1")
        {
            hasAnswer = true;
        }
        if (Request.QueryString["categoryid"] != null)
        {
            if (int.TryParse(Request.QueryString["categoryid"], out categoryID))
                PI.Where += " and categoryid="+categoryID.ToString();
        }
        PI.Where+=" and hasanswer=" + (hasAnswer ? "1" : "0");
        PI.OrderBy = "order by adddate desc";
        List<MatchIns.Model.TWenDa> ds = new MatchIns.BLL.TWenDa().GetPageList(PI).List;
        if (ds.Count == 0)
            rpAsk.FooterTemplate = new EmptyData("<dt>没有找到相关问答。</dt><dd></dd>");
        rpAsk.DataSource = ds;
        rpAsk.DataBind();
        pager.RecordCount = PI.RecordCount;
        pager.AlwaysShow = true;
    }
}